<template>
	<view class="">
		<scroll-view scroll-y="true" class="Hshort">
			<!-- #ifdef H5 -->
			<view class="zdex9 pt20 pb20" :style="{ backgroundImage: 'url(' + cosImageUrl('head_bg.png',true) + ')' }">
				<view class="flex alicen pl20 h60">
					<view class="w40b flex alicen">
						<u-icon name="arrow-left" color="#070707" size="18" @click="goback()"></u-icon>
						<view class="fz24 ml20 nowrap">指点教育高考预测系统</view>
					</view>
				</view>
			</view>
			<!-- #endif -->
			
			<!-- #ifdef MP-WEIXIN-->
			<u-sticky>
				<view class="zdex9 pb20" :style="{ backgroundImage: 'url(' + cosImageUrl('head_bg.png',true) + ')' }">
					<view class="">
						<view class="" :style="{'paddingTop':statusBarHeigh + 'px',}">
							<view class="flex alicen pl20" :style="{'height':menuButtonInfo.height + 'px',}">
								<view class="w40b flex alicen">
									<u-icon name="arrow-left" color="#070707" size="18" @click="goback()"></u-icon>
									<view class="fz24 ml20 nowrap">指点教育高考预测系统</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</u-sticky>
			<!-- #endif -->
			<view class="pl20 pr20">
				<view class="pb20"></view>
				<view class="flex alicen between fz28">
					<view class="nowrap w140">您的分数</view>
					<view class="ml20 w100b txtleft ius10 pt10 pb10 border1 pl10 bored">{{userinfo.grade||'--'}}</view>
				</view>
				<view class="pb20"></view>
				<view class="flex alicen between fz28">
					<view class="nowrap w140">选科</view>
					<view class="ml20 w100b txtleft ius10 pt10 pb10 border1 pl10 bored">首选科目:
						<text>{{userinfo.sxkm}}</text>
						再选科目: <text>{{userinfo.zxkm}}</text>
					</view>
				</view>
				<view class="pb20"></view>
				<view class="flex alicen between fz28">
					<view class="nowrap w140">批次</view>
					<view class="ml20 w100b  txtleft ius10 pt10 pb10 border1 pl10 bored">本科</view>
				</view>
				<view class="mt20 mb10 fz28 col40">填报须知:</view>
				<view class="mb20 fz24 col33">1、当前模拟填报数据以广西考试院公布的《2024
					年高考指南的招生计划篇》为蓝本，采用成熟的新高考预测模型。结合2021-2023年各院校在广西省录取的所有数据，科学的给出各院校专业组的投档概率及专业录取概率。当前填报仅为模拟并不代表最终方案。
				</view>
				<view class="mb20 fz24 col33">2、当前 2024 年招生计划为模拟数据，仅供模拟参考，考试院将于2025年6月发布招生计划,届时本系统将同步更新上线。</view>
				<view class="mb20 fz24 col33">
					3、本系统只提供“本科普通类"1个批次的志愿智能模拟功能，您可以选择适合自己的院校专业组或专业进行模拟，;在正式填报时，以广西考试院公布的最新招生计划为准，并要在广西考试院的官网进行填报。
				</view>
				<view class="flex alicen between colb6">
					<view class="fz30">第 <text class="pt8 pb8 pl20 pr20 border1 boree">{{zyseq}}</text>志愿 </view>
					<view class="fz30">是否专业服从调剂</view>
					<view class="flex alicen">
						<view class="flex alicen mr10" @click="sffBtn(1)">
							<image class="w30 h30"
								:src="sffIdx == '1'?cosImageUrl('/check.png',true):cosImageUrl('/nocheck.png',true)"
								mode="aspectFill"></image>
							<view class="fz28 ml8">服从</view>
						</view>
						<view class="flex alicen" @click="sffBtn(0)">
							<image class="w30 h30"
								:src="sffIdx == '0'?cosImageUrl('/check.png',true):cosImageUrl('/nocheck.png',true)"
								mode="aspectFill"></image>
							<view class="fz28 ml8">不服从</view>
						</view>
					</view>
				</view>
				<view class="pb20"></view>
				<view class="">
					<view class="flex alicen border1 boreb ius10">
						<view class="flex1 pl10 fz28 pt10 pr10 pb10">省市</view>
						<view class="flex2  pl10 fz28 pt10 pb10 flex alicen between pr10"
							style="border-left: 1rpx solid #eeeeee;" @click="byprovice()">
							<view class="">{{proItem.name||'请选择'}}</view>
							<u-icon name="arrow-down" size="18"></u-icon>
						</view>
					</view>
					<view class="flex alicen border1 boreb ius10">
						<view class="flex1 pl10 fz28 pt10 pr10 pb10">院校</view>
						<view class="flex2 bdl1-left1 boree pl10 fz28 pt10 pb10 flex alicen between pr10"
							@click="academy()">
							<view class="">{{academyItem.name||'请选择'}}</view>
							<u-icon name="arrow-down" size="18"></u-icon>
						</view>
					</view>
					<view class="flex alicen border1 boreb ius10">
						<view class="flex1 pl10 fz28 pt10 pr10 pb10">院校代码</view>
						<view class="flex2 bdl1-left1 boree  pl10 fz28 pt10 pb10 flex alicen between pr10 ">
							{{academyItem.value||''}}
						</view>
					</view>
					<view class="flex alicen border1 boreb ius10">
						<view class="flex1 pl10 fz28 pt10 pr10 pb10">综合排名</view>
						<view class="flex2 bdl1-left1 boree  pl10 fz28 pt10 pb10 flex alicen between pr10">{{academyItem.qgRank}}</view>
					</view>
				</view>

				<view class="">
					<view class="flex alicen border1 boreb ius10">
						<view class="flex1 pl10 fz28 pt10 pr10 pb10">专业组</view>
						<view class="flex2  pl10 fz28 pt10 pb10 flex alicen between pr10"
							style="border-left: 1rpx solid #eeeeee;" @click="byzyz()">
							<view class="">{{zyzItem.name||'请选择'}}</view>
							<u-icon name="arrow-down" size="18"></u-icon>
						</view>
					</view>

					<view class="flex alicen border1 boreb ius10">
						<view class="flex1 pl10 fz28 pt10 pr10 pb10">投档概率</view>
						<view class="flex2 bdl1-left1 boree  pl10 fz28 pt10 pb10 flex alicen between pr10 ">
							{{majorrate||''}}%
						</view>
					</view>
					<view class="flex alicen border1 boreb ius10">
						<view class="flex1 pl10 fz28 pt10 pr10 pb10">招生计划数</view>
						<view class="flex2 bdl1-left1 boree  pl10 fz28 pt10 pb10 flex alicen between pr10">
							{{majortotal||''}}
						</view>
					</view>
				</view>


				<view class="" v-for="(zyitem,index1) in majorList" :key="index1">
					<view class="flex alicen border1 boreb ius10">
						<view class="flex1 pl10 fz28 pt10 pr10 pb10">专业{{index1+1}}</view>
						<view class="flex2  pl10 fz28 pt10 pb10 flex alicen between pr10"
							style="border-left: 1rpx solid #eeeeee;" @click="checkzy(zyitem,index1)">
							<view class="">{{zyitem.name||'请选择'}}</view>
							<u-icon name="arrow-down" size="18"></u-icon>
						</view>
					</view>
					<view class="">
						<view class="flex alicen border1 boreb ius10">
							<view class="flex1 pl10 fz28 pt10 pr10 pb10">专业排名</view>
							<view class="flex2 bdl1-left1 boree  pl10 fz28 pt10 pb10 flex alicen between pr10 ">
								{{zyitem.obj&&zyitem.obj.majorPm||'--'}}
							</view>
						</view>
						<view class="flex alicen border1 boreb ius10">
							<view class="flex1 pl10 fz28 pt10 pr10 pb10">招生计划数</view>
							<view class="flex2 bdl1-left1 boree  pl10 fz28 pt10 pb10 flex alicen between pr10">
								{{zyitem.obj&&zyitem.obj.majorPlan||''}}
							</view>
						</view>
						<view class="flex alicen border1 boreb ius10">
							<view class="flex1 pl10 fz28 pt10 pr10 pb10">录取概率</view>
							<view class="flex2 bdl1-left1 boree  pl10 fz28 pt10 pb10 flex alicen between pr10">
								{{zyitem.obj&&zyitem.obj.submitRate||''}}%
							</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
		<com-popup :showPop="popObj.showRightPop" @popStatus="(i) => {popObj.showRightPop = i,popObj.isLoad = {}}">
			<com-selectList :flag="flag" :typesign="popObj.typesign" :popTypeName="popObj.popTypeName"
				:popTypeValue="popObj.popTypeValue" :list="popObj.popList" :title="popObj.popTitle" @submit="submitPop"
				v-if="popObj.isLoad.selectList">
			</com-selectList>
		</com-popup>
		<view class="pt20 pb20 ius100 flexCenter colff fz28 ml20 mr20 bgff000" @click="addshortBtn()">加入填报单</view>
	</view>
</template>

<script>
	import {
		province_list,
		school_level,
		school_types
	} from "@/utils/api/dict.js"
	export default {
		data() {
			return {
				sffIdx: null, //服从调剂的选项卡
				zyseq:0,//第几个志愿
				userinfo: {},
				flag: false,
				proItem: {}, //存选择省份的对象
				academyItem: {}, //保存选择院校的对象
				zyzItem: {}, //选择专业组
				zyItem: {}, //专业的对象
				zyObj: {}, //存储请求对象
				zysubmitRate: '', //存储专业的概率
				majorrate: '', //专业组的概率，
				majortotal: '', //专业组的招生计划
				majorList: [], //专业数组
				zycurrIndex: 1, //选择专业对应的下标
				//弹窗信息
				popObj: {
					popTypeName: "",
					popTypeValue: "",
					showRightPop: false,
					popTitle: "",
					typesign: '', //自定义标识
					popList: [],
					isLoad: {}
				},
			}
		},
		onLoad(options) {
			if(options.length){
				this.zyseq = options.length
			}
			this.mntlist();
		},
		methods: {
			sffBtn(i) {
				this.sffIdx = i
			},
			async mntlist() {
				let params = {
					userId: this.readData('useId')
				}
				let mnt = await this.request.get('/api/getMntbList', {
					params
				})
				if (mnt.code == 200) {
					this.userinfo = mnt.data.member
				}
			},
			// 选择省份
			async byprovice() {
				let params = {
					scrollstr: true
				}
				this.popObj.popTypeName = "省份"
				this.popObj.popTypeValue = "单选"
				this.popObj.typesign = "S" //自定义标识


				let by = await this.request.get('/api/children/list', {
					params
				})
				let temp = []
				by.map((item) => {
					let obj = {
						name: item.name,
						value: item.id
					}
					temp.push(obj)
				})
				this.popObj.popList = temp
				this.popObj.isLoad["selectList"] = true
				this.popObj.showRightPop = true
				this.flag = true
			},
			//选择院校
			async academy() {
				if (!this.proItem?.name) return this.showMsg('请选选择省份')
				let params = {
					province: this.proItem?.value,
					userId: this.readData('useId')
				}
				this.popObj.popTypeName = "院校"
				this.popObj.popTypeValue = "单选"
				this.popObj.typesign = "Y" //自定义标识
				let acad = await this.request.get('/api/schoolListByProvince', {
					params
				})
				console.log('acad', acad)
				if (acad.code == 200) {
					let temp = []
					acad.data.map((item) => {
						let obj = {
							name: item.sname,
							value: item.scode,
							qgRank:item.sranking
						}
						temp.push(obj)
					})
					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
					this.flag = true
				}
			},
			submitPop(item) {
				if (item.potypesignValue == 'S') {
					this.proItem = item.val //保存选择省份 
					this.academyItem = {}
				}
				if (item.potypesignValue == 'Y') {
					this.academyItem = item.val //保存选择院校
					this.zyzItem = {}
				}
				if (item.potypesignValue == 'Z') {
					this.zyzItem = item.val //保存选择专业组
					this.bymajor(item);
				}
				if (item.potypesignValue == 'Zy') {
					this.zyItem = item.val //保存选择专业
					this.majorList[this.zycurrIndex].name = item.val.name
					// console.log('zyItem',this.zyItem)
					this.majorList[this.zycurrIndex].zysubmitRate = this.zysubmitRate
					this.zypmPlan(item)
				}
				this.popObj.showRightPop = false
			},

			async byzyz() {
				if (!this.academyItem?.name) return this.showMsg('请选择院校')
				let params = {
					scode: this.academyItem.value,
					userId: this.readData('useId')
				}
				this.popObj.popTypeName = "专业组"
				this.popObj.popTypeValue = "单选"
				this.popObj.typesign = "Z" //自定义标识
				let zyz = await this.request.get('/api/zyzListBySchoolCode', {
					params
				})
				if (zyz.code == 200) {
					let temp = []
					zyz.data?.zyzList.map((item) => {
						let obj = {
							name: item.zyz,
							value: item.schoolCode
						}
						temp.push(obj)
					})

					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
					this.flag = true
				}
			},
			async bymajor(item) {
				let params = {
					zyz: item.val?.name,
					scode: item.val?.value,
					userId: this.readData('useId')
				}
				let major = await this.request.get('/api/zyListBySchoolCodeZyz', {
					params
				})
				if (major.code == 200) {
					this.majorrate = major.data.submitRate
					this.majortotal = major.data.totalPlan
					this.majorList = major.data.zyzList
				}
			},
			//选择专业
			checkzy(item, index) {
				this.zycurrIndex = index
				this.popObj.popTypeName = "专业"
				this.popObj.popTypeValue = "单选"
				this.popObj.typesign = "Zy" //自定义标识
				let temp = []
				this.majorList.map((item) => {
					let obj = {
						name: item.majorName,
						value: item.majorCode,
					}
					temp.push(obj)
				})
				this.popObj.popList = temp
				this.popObj.isLoad["selectList"] = true
				this.popObj.showRightPop = true
				this.flag = true
			},
			//请求专业
			async zypmPlan(item, index) {
				let params = {
					zy: item.val.name,
					zyz: this.zyzItem.name,
					scode: this.academyItem.value,
					userId: this.readData('useId')
				}
				let zypm = await this.request.get('/api/zypmPlanListBySchoolCodeZyzZy', {
					params
				})
				if (zypm.code == 200) {
					this.$set(this.majorList[this.zycurrIndex],'obj',{})
					this.majorList[this.zycurrIndex].obj = zypm.data.zyzList[0]
					this.majorList[this.zycurrIndex].obj.submitRate  = zypm.data.submitRate
					this.zysubmitRate = zypm.data.submitRate
				}
			},
			//加入填报单
			async addshortBtn() {
				if (this.sffIdx == null) return this.showMsg('请选择是否服从调剂')
				//查找专业组的数据
				let planNums = this.majorList[this.zycurrIndex].obj&&this.majorList[this.zycurrIndex].obj.majorPlan
				let rateSumit = this.majorList[this.zycurrIndex].obj&&this.majorList[this.zycurrIndex].obj.majorrate
				 let qgRank = this.academyItem.qgRank
				let params = {
					id:'',//id
					memberId: this.readData('useId'),//用户的id
					planNums:planNums,//计划数
					province:String(this.proItem && this.proItem.value||''),//省份的code
					qgRank:String(qgRank),//全国排名
					rateSumit: rateSumit,//投档概率
					schoolCode:this.academyItem && this.academyItem.value||'',//学校的code
					sffczytj: String(this.sffIdx),//是否服从调剂
					year:'',//年份
					zyStr:this.parseObjects(this.majorList), //专业的名称 多选逗号拼接
					zyseq:this.zyseq,//第几志愿
					zyzCode:this.zyzItem && this.zyzItem.name||''//专业组的名称
				}
				let result = await this.request.post('/api/saveZytb', params)
				if (result.code == 200) {
					this.successToShow('填报成功', call => {
						this.goback(1)
					})
				}
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.Hshort {
		height: calc(100vh - 120rpx);
		overflow: auto;
	}
</style>